(function () {
    var supportsOrientationChange = 'onorientationchange' in window ? 'orientationchange' : 'resize'; //兼容性处理
    //防抖函数
    function debounce(handler, interval) {
        var timer = null;
        handler(); //首次执行
        return function () {
            if (timer != null) clearTimeout(timer);
            timer = setTimeout(handler, interval)
        }
    }
    //具体的处理函数
    function handler() {
        var clientW = window.innerWidth;//获取当前窗口的宽度
        clientW = clientW >= 640 ? 640 : clientW; //限制最大的宽度
        var fz = clientW / 375 * 100;
        var view_width = document.getElementsByTagName('html')[0].getBoundingClientRect().width;
        var _html = document.getElementsByTagName('html')[0];
        document.documentElement.style.fontSize = fz + "px";
        view_width=view_width>640 ? 640 / 3.75 : view_width / 3.75;
        var sw = view_width / 3.75
        var lw = (fz + sw) / 2 /5
        document.documentElement.style.fontSize = lw + "px";
        _html.style.fontSize = lw + 'px'
        console.log("_html.style.fontSize:", view_width, "fz:", fz + "px")


        // 动态设置div高度
       var conH= $('#container').width();
       var conH2=$('#container').outerWidth();
       var topH=conH2/2
        console.log('container_H:',conH,conH2)
        $('#container').innerHeight(conH2);
        $('#container').css({
            // height:conH2*0.9,
            // top:-topH,
            // 'margin-top':'50%'
        })
    }
    //监听窗口的缩放事件
    window.addEventListener(supportsOrientationChange, debounce(handler, 300));
})()

